import React from 'react';
import { Button, Tooltip, message } from 'antd';
import {
  ShareAltOutlined,
  ExportOutlined,
  ImportOutlined,
  CloudUploadOutlined,
  TeamOutlined,
  GlobalOutlined
} from '@ant-design/icons';
import { PromptTemplate } from '@/types/prompt';

interface PromptShareButtonProps {
  prompt: PromptTemplate;
  onShare?: (prompt: PromptTemplate) => void;
  onExport?: (prompt: PromptTemplate) => void;
  onImport?: () => void;
  type?: 'share' | 'export' | 'import' | 'community';
  size?: 'small' | 'middle' | 'large';
  className?: string;
}

/**
 * 社区分享按钮占位组件
 * 预留用于未来实现社区分享功能
 */
const PromptShareButton: React.FC<PromptShareButtonProps> = ({
  prompt,
  onShare,
  onExport,
  onImport,
  type = 'share',
  size = 'middle',
  className = ''
}) => {
  const handleClick = () => {
    switch (type) {
      case 'share':
        if (onShare) {
          onShare(prompt);
        } else {
          message.info('社区分享功能即将上线');
        }
        break;
      case 'export':
        if (onExport) {
          onExport(prompt);
        } else {
          // 实现导出逻辑
          const exportData = {
            ...prompt,
            exportedAt: new Date().toISOString(),
            version: '1.0'
          };
          const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
          const url = URL.createObjectURL(blob);
          const a = document.createElement('a');
          a.href = url;
          a.download = `prompt-${prompt.name || prompt.id}.json`;
          a.click();
          URL.revokeObjectURL(url);
          message.success('提示词已导出');
        }
        break;
      case 'import':
        if (onImport) {
          onImport();
        } else {
          message.info('导入功能即将上线');
        }
        break;
      case 'community':
        message.info('社区功能正在开发中，敬请期待');
        break;
    }
  };

  const getIcon = () => {
    switch (type) {
      case 'share':
        return <ShareAltOutlined />;
      case 'export':
        return <ExportOutlined />;
      case 'import':
        return <ImportOutlined />;
      case 'community':
        return <TeamOutlined />;
      default:
        return <GlobalOutlined />;
    }
  };

  const getTooltip = () => {
    switch (type) {
      case 'share':
        return '分享到社区';
      case 'export':
        return '导出提示词';
      case 'import':
        return '导入提示词';
      case 'community':
        return '浏览社区提示词';
      default:
        return '';
    }
  };

  const getText = () => {
    switch (type) {
      case 'share':
        return '分享';
      case 'export':
        return '导出';
      case 'import':
        return '导入';
      case 'community':
        return '社区';
      default:
        return '';
    }
  };

  return (
    <Tooltip title={getTooltip()}>
      <Button
        icon={getIcon()}
        size={size}
        onClick={handleClick}
        className={className}
      >
        {getText()}
      </Button>
    </Tooltip>
  );
};

export default PromptShareButton;